package com.taptech.doufu.bean;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by longsiyang on 16/4/8.
 */
public class DFHomeCategoryBean implements Serializable
{
    private Object data;
    private String imgurl;
    private String title;
    private String type;
    private boolean is_login;
    private String show_type;
    private String moreUrl = "";
    private String moreTitle = "";
    private String num;
    private String cover;
    private String url;
    private List<Item> list;

    public List<Item> getList() {
        return list;
    }

    public void setList(List<Item> list) {
        this.list = list;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getMoreUrl() {
        if (data != null && data instanceof String) {
            moreUrl = (String) data;
        }else{
            if (data instanceof Map) {
                Map map = (Map) data;
                moreUrl = (String) map.get("url");
            }
        }
        return moreUrl;
    }

    public String getMoreTitle() {
        if (data !=null && !(data instanceof String)){
            try {
                JSONObject object = new JSONObject((String) data);
                if (object != null) {
                    JSONObject jsonObject = object.optJSONObject("data");
                    if (jsonObject != null) {
                        moreTitle = jsonObject.optString("title");
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return moreTitle;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getImgurl()
    {
        return imgurl;
    }

    public void setImgurl(String imgurl)
    {
        this.imgurl = imgurl;
    }

    public String getTitle()
    {
        return title;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public boolean getIs_login()
    {
        return is_login;
    }

    public void setIs_login(boolean is_login)
    {
        this.is_login = is_login;
    }

    public String getShow_type()
    {
        return show_type;
    }

    public void setShow_type(String show_type)
    {
        this.show_type = show_type;
    }

    public static class Item{
        private String url;
        private String title;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}
